package Physics;

///////////////////////////////////////////
//Gravity
//
//Applies the effect of gravity to the object
///////////////////////////////////////////
public class Gravity extends ForceGenerator
{
	// holds the acceleration due to gravity
	Vector3 m_gravity;
	
	// creates the force generator
	public Gravity(Vector3 gravity) 
	{
		m_gravity = gravity;
	}
	
	// applies the force to the given body
	public void updateForce(RigidBody body, double dt)
	{
		// check if we have a finite mass
		if (!body.hasFiniteMass()) 
				return;
	
		// apply a mass-scaled force to the body
		if (body.m_isAwake)
				body.applyForce(m_gravity.multiply(body.getMass()));			
	}
};